<template>
  <div id="app">
    <!-- 使用骨架屏 -->
    <el-skeleton :loading="loading" animated>
      <template #default>
        <router-view />
      </template>
    </el-skeleton>
  </div>
</template>

<script>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

export default {
  name: 'App',
  setup() {
    const loading = ref(false)

    // 监听路由变化
    const router = useRouter()
    router.beforeEach((to, from, next) => {
      loading.value = true
      next()
    })
    router.afterEach(() => {
      // 延迟关闭，确保组件渲染完成
      setTimeout(() => {
        loading.value = false
      }, 300)
    })

    return {
      loading
    }
  }
}
</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

#app {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  overflow: hidden;
}

body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

html {
  height: 100%;
}
</style>
